﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "NdbObjectSchematic.h"
#include "IElementShapeHandleBehavior.h"
#include "DbDataSchema.h"
#include "WallModule.h"

namespace gcmp
{
    class IDocument;
    class ElementId;
    class IElementParentReporter;
    class IModuleView;
    class IObject;
}

namespace Sample
{
    // 墙体夹点行为组件
    class WallShapeHandleBehavior : public gcmp::NdbObjectSchematic, public gcmp::IElementShapeHandleBehavior
    {
        DBOBJECT_DATA_BEGIN(Sample, WallShapeHandleBehavior, gcmp::NdbObjectSchematic, DDEC5A8E - 6D93 - 4CD9 - A8E2 - 07A55E5E615E, WallModule)
            DATA(gcmp::IDocument*, pDocument)
            DATA(gcmp::ElementId, ModuleViewId)
            DATA(gcmp::ElementId, ElementShapeHandleId)
        DBOBJECT_DATA_END
    public:
        WallShapeHandleBehavior(gcmp::IDocument* pDoc, gcmp::ElementId modelViewId);

        ~WallShapeHandleBehavior() {};

        virtual void GetCalculators(gcmp::ICalculatorCollection* calculators) const override;

        virtual gcmp::IDocument* GetDocument() const override { return m_pDocument; };

        virtual gcmp::ElementId GetElementShapeHandleId() const override { return GetElementShapeHandleId__(); };

        virtual void SetElementShapeHandleId(const gcmp::ElementId& id) override { SetElementShapeHandleId__(id); };

        virtual gcmp::ElementId GetModelViewId() const override { return GetModuleViewId__(); };

        virtual bool Translate(const gcmp::IElementMoveContext& moveContext) override;

        virtual void ReportParents(gcmp::IElementParentReporter& reporter) const override;

        virtual void UpdatePosition() override;

        virtual void UpdatePositionIndexInMasterElement() override {};

        virtual void GetNearestPoint(gcmp::Vector3d& nearPoint) const override;

        virtual gcmp::OwnerPtr<gcmp::IGraphicsElementShape> CreateGrahicsElementShapeInModelView(const gcmp::IModelView* pModelView) const override
        {
            return nullptr;
        };

        virtual bool FinishEditing() override { return true; };

        virtual bool GetHandleCommandString(const gcmp::IObject* commandEnvironment, std::wstring& commandString, gcmp::CommandParameters& commandParamters) const override
        {
            return false;
        };
        virtual gcmp::NdbObject* GetTopOwnerObject() const override;
    };

}